<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title>RPIJM</title>
	<link rel='shortcut icon' href='<?php echo base_url()."images/logo.jpg" ?>' />
	<link rel='stylesheet' href='<?php echo base_url()."style/css/style.css" ?>' />
	<link rel='stylesheet' href='<?php echo base_url()."style/css/table.css" ?>' />
	<link rel='stylesheet' href='<?php echo base_url()."style/css/themes/base/jquery-ui.css" ?>' />
	<link rel='stylesheet' href='<?php echo base_url()."style/css/themes/smoothness/jquery-ui-1.7.2.custom.css" ?>' />
	<script language="javascript">	var site = "<?php echo base_url(); ?>";</script>
	<script type="text/javascript" src="<?php echo base_url(); ?>js/complete.js"></script>
	<script src="<?php echo base_url(); ?>style/js/jquery-1.4.4.min.js" type="text/javascript"></script>
	<script src="<?php echo base_url(); ?>style/js/jquery.numberformatter-1.2.3.js" type="text/javascript"></script>
	<script src="<?php echo base_url(); ?>style/js/jquery.dataTables.min.js" type="text/javascript"></script>
	<script src="<?php echo base_url(); ?>style/js/jquery-ui.js" type="text/javascript"></script>
	<script src="<?php echo base_url(); ?>style/js/general.js" type="text/javascript"></script>
	<script src="<?php echo base_url(); ?>style/js/jquery.validate.js" type="text/javascript"></script>
	<script type="text/javascript">
		var oTable;
		var thn = "<?php echo $thn; ?>";
		 
		$('#kegimg').live( 'click', function () {
			var nTr 	= this.parentNode.parentNode;
			var baseurl = '<?php echo base_url();?>';
			var newUrl	= baseurl.replace("/index.php", "");
			
			var sOut1	= null;
			var curRow	= nTr.rowIndex;
			var id	 	= $.trim(nTr.cells[0].textContent);
			
			if ( this.src.match('details_close') ) {
				this.src 	= newUrl+"style/images/details_open.png";
				$("table tr#static_output"+id).remove();
				var searchString = id;
				
				$("table tr td:contains('" + searchString  + "')").each(function() {
					if ($(this).text() == searchString) {
						$(this).parent().remove();
					}  
				});
			}
			else {
				this.src 	= newUrl+"style/images/details_close.png";
				var sOut 	= $.ajax({
								url		: "matrik_rpijm/getripjm_output/"+ thn + "/" + id,
								complete: function(){$("#loading").hide();},
								global	: false,
								async	: false,
								success	: function(data) {
												sOut1 = data;
											}
								});

				var json= $.parseJSON(sOut1);
				var k 	= 1;
				$(json).each(function(i,val){
					var x=document.getElementById('main-table').insertRow(curRow + k);
					x.setAttribute('id', 'static_output'+id);							
					var a=x.insertCell(0); 	var b=x.insertCell(1); 	var c=x.insertCell(2); 	var d=x.insertCell(3); var e=x.insertCell(4);
					var f=x.insertCell(5); 	var g=x.insertCell(6); 	var h=x.insertCell(7); 	var i=x.insertCell(8); var j=x.insertCell(9); 
					var p=x.insertCell(10); var l=x.insertCell(11); var m=x.insertCell(12); var n=x.insertCell(13); 
					var o=x.insertCell(14); var q=x.insertCell(15); var r=x.insertCell(16); 
					
					g.align="right"; h.align="right"; i.align="right"; j.align="right"; p.align="right"; l.align="right";
					m.align="right"; n.align="right"; o.align="right"; q.align="right";
					
					a.innerHTML= '<input type="hidden" value="'+val.kd_kegiatan+'">'; 
					c.innerHTML= ""; e.innerHTML= ""; f.innerHTML= ""; q.innerHTML= ""; r.innerHTML= "";
					b.innerHTML= '<img id="outputimg" src="<?php echo base_url(); ?>style/images/details_open.png">'+val.output;
					d.innerHTML= val.nama_output; 
					g.innerHTML= number_format(val.apbn);
					h.innerHTML= number_format(val.pln);
					i.innerHTML= number_format(val.hibah);
					j.innerHTML= number_format(val.apbd1);
					p.innerHTML= number_format(val.apbd2);
					l.innerHTML= number_format(val.pdam);
					m.innerHTML= number_format(val.swasta);
					n.innerHTML= number_format(val.masy);
					o.innerHTML= number_format(val.dak);
					
					k++;
				});
			}
		} );
		
		$('#outputimg').live( 'click', function () {
			var nTr 	= this.parentNode.parentNode;
			var baseurl = '<?php echo base_url();?>';
			var newUrl	= baseurl.replace("/index.php", "");
			
			var sOut1	= null;
			var curRow	= nTr.rowIndex;
			var id	 	= $.trim(nTr.cells[1].textContent);
			var test_str= $.trim(nTr.cells[0].innerHTML);

			var start_pos 	= test_str.indexOf('value="') + 7;
			var end_pos 	= test_str.indexOf('"',start_pos);
			var kdKeg 		= test_str.substring(start_pos, end_pos);
			var idTr		= kdKeg+"_"+id;
			
			if ( this.src.match('details_close') ) {
				this.src 	= newUrl+"style/images/details_open.png";
				$("table tr#static_suboutput"+idTr+"").remove();
				$("table tr td:contains(output:"+ id +")").parent().remove(); 
			}
			else {
				this.src 	= newUrl+"style/images/details_close.png";
				
				var sOut 	= $.ajax({
								url		: "matrik_rpijm/getripjm_suboutput/"+ thn + "/" + kdKeg+'/'+ id,
								complete: function(){$("#loading").hide();},
								global	: false,
								async	: false,
								success	: function(data) {
												sOut1 = data;
											}
								});

				var json= $.parseJSON(sOut1);
				var k 	= 1;
				$(json).each(function(i,val){
					var x=document.getElementById('main-table').insertRow(curRow + k);
					x.setAttribute('id', 'static_suboutput'+idTr);
					x.style.backgroundColor="#CECEEA";
					var a=x.insertCell(0); 	var b=x.insertCell(1); 	var c=x.insertCell(2); 	var d=x.insertCell(3); var e=x.insertCell(4);
					var f=x.insertCell(5); 	var g=x.insertCell(6); 	var h=x.insertCell(7); 	var i=x.insertCell(8); var j=x.insertCell(9); 
					var p=x.insertCell(10); var l=x.insertCell(11); var m=x.insertCell(12); var n=x.insertCell(13); 
					var o=x.insertCell(14); var q=x.insertCell(15); var r=x.insertCell(16); 
					
					g.align="right"; h.align="right"; i.align="right"; j.align="right"; p.align="right"; l.align="right";
					m.align="right"; n.align="right"; o.align="right"; q.align="right"; r.innerHTML= ""; 
					
					a.innerHTML= '<input type="hidden" value="'+val.kd_kegiatan+'"><span style="color:#CECEEA;">'+val.kd_kegiatan+'</span>'; 
					b.innerHTML= '<input type="hidden" value="'+val.output+'"><span style="color:#CECEEA;">output:'+val.output+'</span>'; 
					c.innerHTML= '<img id="suboutputimg" src="<?php echo base_url(); ?>style/images/details_open.png">'+val.sub_output;
					d.innerHTML= val.nama_suboutput; 
					e.innerHTML= ""; f.innerHTML= ""; q.innerHTML= "";
					g.innerHTML= number_format(val.apbn);
					h.innerHTML= number_format(val.pln);
					i.innerHTML= number_format(val.hibah);
					j.innerHTML= number_format(val.apbd1);
					p.innerHTML= number_format(val.apbd2);
					l.innerHTML= number_format(val.pdam);
					m.innerHTML= number_format(val.swasta);
					n.innerHTML= number_format(val.masy);
					o.innerHTML= number_format(val.dak);
					
					k++;
				});
			}
		} );
		
		$('#suboutputimg').live( 'click', function () {
			var nTr 	= this.parentNode.parentNode;
			var baseurl = '<?php echo base_url();?>';
			var newUrl	= baseurl.replace("/index.php", "");
			
			var sOut1	= null;
			var curRow	= nTr.rowIndex;
			var vKeg	= $.trim(nTr.cells[0].innerHTML);
			var vOut	= $.trim(nTr.cells[1].innerHTML);
			var id		= $.trim(nTr.cells[2].textContent);

			var start_pos 	= vKeg.indexOf('value="') + 7;
			var end_pos 	= vKeg.indexOf('"',start_pos);
			var kdKeg 		= vKeg.substring(start_pos, end_pos);
			
			var start_pos 	= vOut.indexOf('value="') + 7;
			var end_pos 	= vOut.indexOf('"',start_pos);
			var kdOut 		= vOut.substring(start_pos, end_pos);
			var idTr		= kdKeg+"_"+kdOut+"_"+id;
			
			if ( this.src.match('details_close') ) {
				this.src 	= newUrl+"style/images/details_open.png";
				$("table tr#static_kabkota"+idTr+"").remove();
			}
			else {
				this.src 	= newUrl+"style/images/details_close.png";

				var sOut 	= $.ajax({
								url		: "matrik_rpijm/getripjm_kabkota/"+thn + "/" + kdKeg+"/"+kdOut+"/"+ id,
								complete: function(){$("#loading").hide();},
								global	: false,
								async	: false,
								success	: function(data) {
												sOut1 = data;
											}
								});

				var json= $.parseJSON(sOut1);
				var k 	= 1;
				$(json).each(function(i,val){
					var x=document.getElementById('main-table').insertRow(curRow + k);			
					x.setAttribute('id', 'static_kabkota'+idTr);		
					x.style.backgroundColor="#E6E6FA";
					var a=x.insertCell(0); 	var b=x.insertCell(1); 	var c=x.insertCell(2); 	var d=x.insertCell(3); var e=x.insertCell(4);
					var f=x.insertCell(5); 	var g=x.insertCell(6); 	var h=x.insertCell(7); 	var i=x.insertCell(8); var j=x.insertCell(9); 
					var p=x.insertCell(10); var l=x.insertCell(11); var m=x.insertCell(12); var n=x.insertCell(13); 
					var o=x.insertCell(14); var q=x.insertCell(15); var r=x.insertCell(15); 
					
					g.align="right"; h.align="right"; i.align="right"; j.align="right"; p.align="right"; l.align="right";
					m.align="right"; n.align="right"; o.align="right"; r.innerHTML= "";
					
					a.innerHTML= '<input type="hidden" value="'+val.kd_kegiatan+'"><span style="color:#E6E6FA;">'+val.kd_kegiatan+'</span>'; 
					b.innerHTML= '<input type="hidden" value="'+val.output+'"><span style="color:#E6E6FA;">output:'+val.output+'</span>'; 
					c.innerHTML= '<input type="hidden" value="'+val.sub_output+'">'; 
					d.innerHTML= ""; 
					e.innerHTML= '<img id="kabkotaimg" src="<?php echo base_url(); ?>style/images/details_open.png">'+val.kabkota; 
					f.innerHTML= val.lokasirinci; 
					g.innerHTML= number_format(val.apbn);
					h.innerHTML= number_format(val.pln);
					i.innerHTML= number_format(val.hibah);
					j.innerHTML= number_format(val.apbd1);
					p.innerHTML= number_format(val.apbd2);
					l.innerHTML= number_format(val.pdam);
					m.innerHTML= number_format(val.swasta);
					n.innerHTML= number_format(val.masy);
					o.innerHTML= number_format(val.dak);
					q.innerHTML= "";

					k++;
				});
			}
		} );
		
		$('#kabkotaimg').live( 'click', function () {
			var nTr 	= this.parentNode.parentNode;
			var baseurl = '<?php echo base_url();?>';
			var newUrl	= baseurl.replace("/index.php", "");
			
			var sOut1	= null;
			var curRow	= nTr.rowIndex;
			var vKeg	= $.trim(nTr.cells[0].innerHTML);
			var vOut	= $.trim(nTr.cells[1].innerHTML);
			var vSub	= $.trim(nTr.cells[2].innerHTML);
			var id		= $.trim(nTr.cells[4].textContent);

			var start_pos 	= vKeg.indexOf('value="') + 7;
			var end_pos 	= vKeg.indexOf('"',start_pos);
			var kdKeg 		= vKeg.substring(start_pos, end_pos);
			
			var start_pos 	= vOut.indexOf('value="') + 7;
			var end_pos 	= vOut.indexOf('"',start_pos);
			var kdOut 		= vOut.substring(start_pos, end_pos);
			
			var start_pos 	= vSub.indexOf('value="') + 7;
			var end_pos 	= vSub.indexOf('"',start_pos);
			var kdSub 		= vSub.substring(start_pos, end_pos);
			
			var idTr		= kdKeg+"_"+kdOut+"_"+kdSub+"_"+ id.replace(".","");

			if ( this.src.match('details_close') ) {
				this.src 	= newUrl+"style/images/details_open.png";
				$("table tr#static_uraian"+idTr+"").remove();
			}
			else {
				this.src 	= newUrl+"style/images/details_close.png";

				var sOut 	= $.ajax({
								url		: "pilih_usulanmp/getripjmData/"+thn + "/" + kdKeg+"/"+kdOut+"/"+kdSub+"/"+ id,
								beforeSend: function(){ $("#loading").show(); },
								complete: function(){$("#loading").hide();},
								global	: false,
								async	: false,
								success	: function(data) {
												sOut1 = data;
											}
								});

				var json= $.parseJSON(sOut1);
				var k 	= 1;
				$(json).each(function(i,val){
					var x=document.getElementById('main-table').insertRow(curRow + k);			
					x.setAttribute('id', 'static_uraian'+idTr);
					x.style.backgroundColor="#E6E6FA";
					var a=x.insertCell(0); var b=x.insertCell(1); var c=x.insertCell(2); var d=x.insertCell(3); var e=x.insertCell(4);
					var f=x.insertCell(5); var g=x.insertCell(6); var h=x.insertCell(7); var i=x.insertCell(8); var j=x.insertCell(9); 
					var p=x.insertCell(10); var l=x.insertCell(11); var m=x.insertCell(12); var n=x.insertCell(13); 
					var o=x.insertCell(14); var q=x.insertCell(15); var r=x.insertCell(16); 
					
					g.align="right"; h.align="right"; i.align="right"; j.align="right"; p.align="right"; l.align="right";
					m.align="right"; n.align="right"; o.align="right";
					
					a.innerHTML= '<input type="hidden" value="'+val.kd_kegiatan+'"><span style="color:#E6E6FA;">'+val.kd_kegiatan+'</span>'; 
					b.innerHTML= '<input type="hidden" value="'+val.output+'"><span style="color:#E6E6FA;">output:'+val.output+'</span>'; 
					c.innerHTML= '<input type="hidden" value="'+val.suboutput+'">'; 
					d.innerHTML= val.uraian; 
					e.innerHTML= ""; 
					f.innerHTML= val.lokasirinci; 
					g.innerHTML= number_format(val.apbn);
					h.innerHTML= number_format(val.pln);
					i.innerHTML= number_format(val.hibah);
					j.innerHTML= number_format(val.apbd1);
					p.innerHTML= number_format(val.apbd2);
					l.innerHTML= number_format(val.pdam);
					m.innerHTML= number_format(val.swasta);
					n.innerHTML= number_format(val.masy);
					o.innerHTML= number_format(val.dak);
					q.innerHTML= "";
					r.innerHTML= '<input type="checkbox" name="pilih" id="pilih_'+val.id_rpijm+'" value="'+val.id_rpijm+'" onChange="getStat(this)">';
					
					if (val.status == 1) $("#pilih_"+val.id_rpijm).attr("checked",true);
					
					k++;
				});
			} 
		} );
		
		function getStat(pVal){
			if (!$(pVal).is(':checked')) {
				var stat = 0;
			} else {
				var stat = 1;
			}
			
			var sOut 	= $.ajax({
								url		: "pilih_usulanmp/setStatus/"+ $(pVal).val() + "/" + stat,
								complete: function(){$("#loading").hide();},
								global	: false,
								async	: false,
								success	: function(data) {
												sOut1 = data;
											}
								});
		}
		
		function load_options(id, index){
			$("#loading").show();
			
			$("#"+index).html('<option value="">Pilih '+index+'</option>');
			$.ajax({
				url: "matrik_rpijm/get"+index+"/"+id,
				complete: function(){$("#loading").hide();},
				success: function(data) {
					$("#"+index).html(data);
				}
			})
		}
	</script>
	
</head>
<body>
	<?php $this->load->view('layout/header-nav'); ?>
	<?php $this->load->view('usulan_mp/pilih/mrpijm_list'); ?>
</body>
</html>

